home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / SHIFTER.C < prev    next >
Text File  |  1989-12-30  |  640b  |  24 lines

  1. main()
  2. {
  3. int small, big, index, count;
  4.  
  5.    printf("       shift left      shift right\n\n");
  6.    small = 1;
  7.    big = 0x4000;
  8.    for(index = 0;index < 17;index++) {
  9.       printf("%8d %8x %8d %8x\n",small,small,big,big);
  10.       small = small << 1;
  11.       big = big >> 1;
  12.    }
  13.  
  14.    printf("\n");
  15.    count = 2;
  16.    small = 1;
  17.    big = 0x4000;
  18.    for(index = 0;index < 9;index++) {
  19.       printf("%8d %8x %8d %8x\n",small,small,big,big);
  20.       small = small << count;
  21.       big = big >> count;
  22.    }
  23. }
  24.